<template>
	<view class="courier-number-wp">
		<view class="courier-number-cont">
			<view>选择快递
				<picker class="picker" @change="bindPickerChange" :value="index" :range="array">
					<view class="uni-input">{{array[index]}}</view>
				</picker>
			</view>
			<view>快递单号<input class="input" type="text" value="" v-model="val" placeholder="请输入快递单号" placeholder-class="inputpl" /></view>
		</view>
		<button class="btn" type="default" @click="ok">确认</button>
	</view>
</template>

<script>
	export default {
		name: 'CourierNumber',
		data() {
			return {
				index: 0,
				val: '',
				id: {},
				array: ['请选择快递公司', '顺丰', '申通', '韵达快运', '天天快递', '圆通速递', '中通速递', 'ems快递', '汇通快运', '全峰快递', '宅急送', 'aae全球专递', '安捷快递',
					'安信达快递', '彪记快递', 'bht', '百福东方国际物流', '中国东方（COE）', '长宇物流', '大田物流', '德邦物流', 'dhl', 'dpex', 'd速快递', '递四方',
					'fedex（国外）', '飞康达物流', '凤凰快递', '飞快达', '国通快递', '港中能达物流', '广东邮政物流', '共速达', '恒路物流', '华夏龙物流', '海红', '海外环球', '佳怡物流',
					'京广速递', '急先达', '佳吉物流', '加运美物流', '金大物流', '嘉里大通', '晋越快递', '快捷速递', '联邦快递（国内）', '联昊通物流', '龙邦物流', '立即送', '乐捷递', '民航快递',
					'美国快递', '门对门', 'OCS', '配思货运', '全晨快递', '全际通物流', '全日通快递', '全一快递', '如风达', '三态速递', '盛辉物流', '速尔物流', '盛丰物流', '赛澳递',
					'天地华宇', 'tnt', 'ups', '万家物流', '文捷航空速递', '伍圆', '万象物流', '新邦物流', '信丰物流', '亚风速递', '一邦速递', '优速物流', '邮政包裹挂号信',
					'邮政国际包裹挂号信', '远成物流', '源伟丰快递', '元智捷诚快递', '运通快递', '越丰物流', '源安达', '银捷速递', '中铁快运', '中邮物流', '忠信达', '芝麻开门'
				],
				array1: ['shunfeng', 'shentong', 'yunda', 'tiantian', 'yuantong', 'zhongtong', 'ems', 'huitongkuaidi',
					'quanfengkuaidi', 'zhaijisong', 'aae', 'anjie', 'anxindakuaixi', 'biaojikuaidi', 'bht', 'baifudongfang', 'coe',
					'changyuwuliu', 'datianwuliu', 'debangwuliu', 'dhl', 'dpex', 'dsukuaidi', 'disifang', 'fedex', 'feikangda',
					'fenghuangkuaidi', 'feikuaida', 'guotongkuaidi', 'ganzhongnengda', 'guangdongyouzhengwuliu', 'gongsuda',
					'hengluwuliu', 'huaxialongwuliu', 'haihongwangsong', 'haiwaihuanqiu', 'jiayiwuliu', 'jinguangsudikuaijian',
					'jixianda', 'jjwl', 'jymwl', 'jindawuliu', 'jialidatong', 'jykd', 'kuaijiesudi', 'lianb', 'lianhaowuliu',
					'longbanwuliu', 'lijisong', 'lejiedi', 'minghangkuaidi', 'meiguokuaidi', 'menduimen', 'ocs', 'peisihuoyunkuaidi',
					'quanchenkuaidi', 'quanjitong', 'quanritongkuaidi', 'quanyikuaidi', 'rufengda', 'santaisudi', 'shenghuiwuliu',
					'sue', 'shengfeng', 'saiaodi', 'tiandihuayu', 'tnt', 'ups', 'wanjiawuliu', 'wenjiesudi', 'wuyuan', 'wxwl',
					'xinbangwuliu', 'xinfengwuliu', 'yafengsudi', 'yibangwuliu', 'youshuwuliu', 'youzhengguonei', 'youzhengguoji',
					'yuanchengwuliu', 'yuanweifeng', 'yuanzhijiecheng', 'yuntongkuaidi', 'yuefengwuliu', 'yad', 'yinjiesudi',
					'zhongtiekuaiyun', 'zhongyouwuliu', 'zhongxinda', 'zhimakaimen'
				]
			}
		},
		onLoad() {
			this.id = this.options;
		},
		methods: {
			bindPickerChange(e) {
				this.index = e.detail.value;
			},
			ok() {
				if (this.index == 0) {
					uni.showToast({
						title: '请输选择快递公司',
						icon: 'none'
					})
				} else {
					if (this.val == '') {
						uni.showToast({
							title: '请输入快递单号',
							icon: 'none'
						})
					} else {
						var _this = this;
						this.$axios('op/express', 'POST', 'order', {
							id: _this.id.id2,
							expresscom: _this.array[_this.index],
							expresssn: _this.val,
							express: _this.array1[_this.index - 1]
						}).then(res => {
							if (res.data.code = 200) {
								uni.showModal({
									title: '快递单号单号填写' + res.data.data,
									showCancel: false,
									success() {
										uni.navigateTo({
											url: '/pages/order/orderInfo?id=' + _this.id.id
										})
									}
								})
							}
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
	}

	.courier-number-wp {
		overflow: hidden;
	}

	.courier-number-cont {
		background-color: #fff;
		margin-top: 30upx;
		padding: 0 20upx;

		view {
			border-bottom: 1upx #f2f2f2 solid;
			font-size: 28upx;
			line-height: 80upx;
		}

		view:nth-child(2) {
			border: none;
		}
	}

	.picker,
	.input {
		display: inline-block;
		margin-left: 30upx;
		color: #909399;
	}

	.courier-number-cont .uni-input {
		font-size: 32upx;
	}

	.input {
		vertical-align: middle;
	}

	.inputpl {
		font-size: 32upx;
	}

	.btn {
		background-color: $base-color;
		color: #fff;
		margin-top: 30upx;
		letter-spacing: 10upx;
		width: 96%;
	}
</style>
